package com.TwinBlade.PicturePassword;

import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.preference.PreferenceManager;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

public class cs extends View
  implements View.OnTouchListener
{
  private List A = new ArrayList();
  private List B = new ArrayList();
  private List C = new ArrayList();
  private List D = new ArrayList();
  private List E = Arrays.asList(new String[] { "FirstGestureData", "SecondGestureData", "ThirdGestureData", "FourthGestureData", "FifthGestureData" });
  private float a;
  private float b;
  private float c;
  private float d;
  private List e = new ArrayList();
  private int f = 0;
  private String g = "";
  private Context h;
  private SharedPreferences i;
  private List j = new ArrayList();
  private Paint k;
  private Paint l;
  private Paint m;
  private float n = -1.0F;
  private float o = -1.0F;
  private int p;
  private int q;
  private int r;
  private List s = new ArrayList();
  private List t = new ArrayList();
  private List u = new ArrayList();
  private List v = new ArrayList();
  private List w = new ArrayList();
  private List x = new ArrayList();
  private List y = new ArrayList();
  private List z = new ArrayList();

  public cs(Context paramContext)
  {
    super(paramContext);
    setFocusable(true);
    setFocusableInTouchMode(true);
    setOnTouchListener(this);
    this.h = paramContext;
    this.i = PreferenceManager.getDefaultSharedPreferences(Utilities.c);
    int i1 = this.i.getInt("ThemeColor", Color.argb(255, 57, 146, 181));
    this.m = new Paint();
    this.m.setColor(-1);
    this.m.setAntiAlias(true);
    this.m.setStrokeWidth(7.0F);
    this.k = new Paint();
    this.k.setColor(Color.argb(Color.alpha(i1), Color.red(i1), Color.green(i1), Color.blue(i1)));
    this.k.setAntiAlias(true);
    this.k.setStrokeWidth(7.0F);
    this.l = new Paint();
    this.l.setColor(Color.argb(Color.alpha(i1), Color.red(i1), Color.green(i1), Color.blue(i1)));
    this.l.setAntiAlias(true);
    this.l.setStyle(Paint.Style.STROKE);
    this.l.setStrokeWidth(7.0F);
    String str1 = this.i.getString("FirstGestureType", "none");
    String str2 = this.i.getString("SecondGestureType", "none");
    String str3 = this.i.getString("ThirdGestureType", "none");
    String str4 = this.i.getString("FourthGestureType", "none");
    String str5 = this.i.getString("FifthGestureType", "none");
    if (!str1.equals("none"))
    {
      this.e.add(str1);
      this.C.add(this.s);
      this.D.add(this.x);
    }
    if (!str2.equals("none"))
    {
      this.e.add(str2);
      this.C.add(this.t);
      this.D.add(this.y);
    }
    if (!str3.equals("none"))
    {
      this.e.add(str3);
      this.C.add(this.u);
      this.D.add(this.z);
    }
    if (!str4.equals("none"))
    {
      this.e.add(str4);
      this.C.add(this.v);
      this.D.add(this.A);
    }
    if (!str5.equals("none"))
    {
      this.e.add(str5);
      this.C.add(this.w);
      this.D.add(this.B);
    }
    this.e.add("done");
    this.p = Integer.parseInt(this.i.getString("LinearValidationErrorTolerance", "75"));
    this.q = Integer.parseInt(this.i.getString("CirclePosValidationErrorTolerance", "70"));
    this.r = Integer.parseInt(this.i.getString("CircleRadiusValidationErrorTolerance", "45"));
    c();
    setMode(0);
  }

  private float a(float paramFloat1, float paramFloat2)
  {
    return (int)Math.sqrt(paramFloat1 * paramFloat1 + paramFloat2 * paramFloat2);
  }

  private float a(float paramFloat1, float paramFloat2, float paramFloat3, float paramFloat4)
  {
    return (int)Math.sqrt((paramFloat3 - paramFloat1) * (paramFloat3 - paramFloat1) + (paramFloat4 - paramFloat2) * (paramFloat4 - paramFloat2));
  }

  private void a()
  {
    if (this.g.equals("point"))
      Utilities.a(this.h, Integer.toString(1 + this.f) + ") " + this.h.getString(2131296445), 0, true);
    do
    {
      return;
      if (this.g.equals("line"))
      {
        Utilities.a(this.h, Integer.toString(1 + this.f) + ") " + this.h.getString(2131296446), 0, true);
        return;
      }
    }
    while (!this.g.equals("circle"));
    Utilities.a(this.h, Integer.toString(1 + this.f) + ") " + this.h.getString(2131296447), 0, true);
  }

  private void b()
  {
    float f1 = 0.0F;
    float f2 = ((d)this.j.get(0)).b;
    float f3 = ((d)this.j.get(0)).a;
    Iterator localIterator = this.j.iterator();
    float f4 = f2;
    float f5 = 0.0F;
    float f6 = f3;
    while (true)
    {
      if (!localIterator.hasNext())
      {
        float f7 = f1 - f6;
        float f8 = f5 - f4;
        float f9 = f4 + f8 / 2.0F;
        float f10 = f6 + f7 / 2.0F;
        float f11 = (f7 + f8) / 4.0F;
        ((List)this.C.get(this.f)).clear();
        ((List)this.C.get(this.f)).add(Float.valueOf(f10));
        ((List)this.C.get(this.f)).add(Float.valueOf(f9));
        ((List)this.C.get(this.f)).add(Float.valueOf(f11));
        return;
      }
      d locald = (d)localIterator.next();
      if (locald.b > f5)
        f5 = locald.b;
      if (locald.b < f4)
        f4 = locald.b;
      if (locald.a > f1)
        f1 = locald.a;
      if (locald.a < f6)
        f6 = locald.a;
    }
  }

  private void c()
  {
    int i1 = 0;
    if (i1 >= this.C.size())
      return;
    String[] arrayOfString = this.i.getString((String)this.E.get(i1), "0").split(";");
    int i2 = arrayOfString.length;
    for (int i3 = 0; ; i3++)
    {
      if (i3 >= i2)
      {
        i1++;
        break;
      }
      String str = arrayOfString[i3];
      ((List)this.D.get(i1)).add(Float.valueOf(str));
    }
  }

  private boolean d()
  {
    if (a(this.c, this.d) > 120.0F);
    for (int i1 = 0; ; i1 = 1)
    {
      Iterator localIterator = this.j.iterator();
      int i2 = 1;
      if (!localIterator.hasNext())
      {
        if (i1 != 0)
          break label303;
        Utilities.a(this.h, this.h.getString(2131296443), 3, true);
      }
      while (true)
      {
        if ((i1 == 0) || (i2 == 0))
          break label329;
        return true;
        d locald = (d)localIterator.next();
        if ((a(locald.a, locald.b, ((Float)((List)this.C.get(this.f)).get(0)).floatValue(), ((Float)((List)this.C.get(this.f)).get(1)).floatValue()) <= 85.0F + ((Float)((List)this.C.get(this.f)).get(2)).floatValue()) && (a(locald.a, locald.b, ((Float)((List)this.C.get(this.f)).get(0)).floatValue(), ((Float)((List)this.C.get(this.f)).get(1)).floatValue()) >= ((Float)((List)this.C.get(this.f)).get(2)).floatValue() - 85.0F))
          break;
        i2 = 0;
        break;
        label303: if (i2 == 0)
          Utilities.a(this.h, this.h.getString(2131296444), 3, true);
      }
      label329: return false;
    }
  }

  private boolean e()
  {
    int i1 = 0;
    boolean bool = true;
    if (i1 >= this.C.size())
      return bool;
    if (this.C.get(i1) != null)
    {
      if (((List)this.C.get(i1)).size() != 2)
        break label175;
      if (a(((Float)((List)this.C.get(i1)).get(0)).floatValue(), ((Float)((List)this.C.get(i1)).get(1)).floatValue(), ((Float)((List)this.D.get(i1)).get(0)).floatValue(), ((Float)((List)this.D.get(i1)).get(1)).floatValue()) > this.p)
        bool = false;
    }
    while (true)
    {
      i1++;
      break;
      label175: if (((List)this.C.get(i1)).size() == 4)
      {
        if (a(((Float)((List)this.C.get(i1)).get(0)).floatValue(), ((Float)((List)this.C.get(i1)).get(1)).floatValue(), ((Float)((List)this.D.get(i1)).get(0)).floatValue(), ((Float)((List)this.D.get(i1)).get(1)).floatValue()) > this.p)
          bool = false;
        if (a(((Float)((List)this.C.get(i1)).get(2)).floatValue(), ((Float)((List)this.C.get(i1)).get(3)).floatValue(), ((Float)((List)this.D.get(i1)).get(2)).floatValue(), ((Float)((List)this.D.get(i1)).get(3)).floatValue()) > this.p)
          bool = false;
      }
      else if (((List)this.C.get(i1)).size() == 3)
      {
        if (a(((Float)((List)this.C.get(i1)).get(0)).floatValue(), ((Float)((List)this.C.get(i1)).get(1)).floatValue(), ((Float)((List)this.D.get(i1)).get(0)).floatValue(), ((Float)((List)this.D.get(i1)).get(1)).floatValue()) > this.q)
          bool = false;
        if (Math.abs(((Float)((List)this.C.get(i1)).get(2)).floatValue() - ((Float)((List)this.D.get(i1)).get(2)).floatValue()) > this.r)
          bool = false;
      }
    }
  }

  private void f()
  {
    for (int i1 = 0; ; i1++)
    {
      if (i1 >= this.C.size())
        return;
      ((List)this.C.get(i1)).clear();
    }
  }

  private void setMode(int paramInt)
  {
    if (paramInt == 0)
    {
      this.g = ((String)this.e.get(this.f));
      a();
    }
    do
    {
      return;
      if (paramInt == 1)
      {
        this.f = (1 + this.f);
        this.g = ((String)this.e.get(this.f));
        if (this.g.equals("done"))
        {
          if (e())
          {
            Utilities.a(this.h, this.h.getString(2131296441), 1, true);
            SaveActivity.a();
            return;
          }
          Utilities.a(this.h, this.h.getString(2131296442), 2, true);
          f();
          setMode(-1);
          return;
        }
        a();
        return;
      }
    }
    while (paramInt != -1);
    this.f = 0;
    setMode(0);
  }

  public void onDraw(Canvas paramCanvas)
  {
    if ((this.n != -1.0F) && (this.o != -1.0F))
      paramCanvas.drawCircle(this.n, this.o, 12.0F, this.m);
    int i1 = 0;
    if (i1 >= this.C.size())
      return;
    if (this.C.get(i1) != null)
    {
      if (((List)this.C.get(i1)).size() != 2)
        break label157;
      paramCanvas.drawCircle(((Float)((List)this.C.get(i1)).get(0)).floatValue(), ((Float)((List)this.C.get(i1)).get(1)).floatValue(), 12.0F, this.k);
    }
    while (true)
    {
      i1++;
      break;
      label157: if (((List)this.C.get(i1)).size() == 4)
        paramCanvas.drawLine(((Float)((List)this.C.get(i1)).get(0)).floatValue(), ((Float)((List)this.C.get(i1)).get(1)).floatValue(), ((Float)((List)this.C.get(i1)).get(2)).floatValue(), ((Float)((List)this.C.get(i1)).get(3)).floatValue(), this.k);
      else if (((List)this.C.get(i1)).size() == 3)
        paramCanvas.drawCircle(((Float)((List)this.C.get(i1)).get(0)).floatValue(), ((Float)((List)this.C.get(i1)).get(1)).floatValue(), ((Float)((List)this.C.get(i1)).get(2)).floatValue(), this.l);
    }
  }

  public boolean onTouch(View paramView, MotionEvent paramMotionEvent)
  {
    while (true)
    {
      try
      {
        paramMotionEvent.wait(16L);
        if (this.g.equals("circle"))
        {
          if (paramMotionEvent.getAction() == 0)
          {
            this.a = paramMotionEvent.getX();
            this.b = paramMotionEvent.getY();
            this.n = this.a;
            this.o = this.b;
            invalidate();
          }
          d locald = new d();
          locald.a = paramMotionEvent.getX();
          locald.b = paramMotionEvent.getY();
          this.j.add(locald);
          if (paramMotionEvent.getAction() == 1)
          {
            this.n = -1.0F;
            this.o = -1.0F;
            this.c = (paramMotionEvent.getX() - this.a);
            this.d = (paramMotionEvent.getY() - this.b);
            b();
            if (d())
            {
              setMode(1);
              invalidate();
              this.j.clear();
            }
          }
          else
          {
            return true;
          }
          ((List)this.C.get(this.f)).clear();
          setMode(0);
          continue;
        }
      }
      catch (Exception localException)
      {
        return false;
        if ((!this.g.equals("point")) && (!this.g.equals("line")))
          continue;
        if (paramMotionEvent.getAction() == 0)
        {
          this.a = paramMotionEvent.getX();
          this.b = paramMotionEvent.getY();
          this.n = this.a;
          this.o = this.b;
          invalidate();
        }
        if (paramMotionEvent.getAction() != 1)
          continue;
        this.n = -1.0F;
        this.o = -1.0F;
        if (this.g.equals("point"))
        {
          ((List)this.C.get(this.f)).clear();
          ((List)this.C.get(this.f)).add(Float.valueOf(paramMotionEvent.getX()));
          ((List)this.C.get(this.f)).add(Float.valueOf(paramMotionEvent.getY()));
          invalidate();
          setMode(1);
          continue;
        }
      }
      finally
      {
      }
      if (this.g.equals("line"))
      {
        ((List)this.C.get(this.f)).clear();
        ((List)this.C.get(this.f)).add(Float.valueOf(this.a));
        ((List)this.C.get(this.f)).add(Float.valueOf(this.b));
        ((List)this.C.get(this.f)).add(Float.valueOf(paramMotionEvent.getX()));
        ((List)this.C.get(this.f)).add(Float.valueOf(paramMotionEvent.getY()));
      }
    }
  }
}

/* Location:           D:\Studium\Bachelorarbeit\BA Marcus Wobig\BA\BA\Decompiler\PicturePassword APK\Programm\PicturePassword_dex2jar.jar
 * Qualified Name:     com.TwinBlade.PicturePassword.cs
 * JD-Core Version:    0.6.2
 */